로딩 중이에요... 🐣
[코담]
웹개발·실전 프로젝트·AI까지, 파이썬·장고의 모든것을 담아낸 강의와 개발 노트
3. 배포설정3 | ✅ 저자: 이유정(박사)
AIRestaurant/ # 프로젝트 루트 디렉토리
├── .ebextensions/ # AWS Elastic Beanstalk 설정 디렉토리
│ ├── 01_installation.config # 설치
│ └── 02_django.config # Django 관련 명령어 및 설정
├── .gitignore
├── 기타 파일 및 디렉토리들...
.ebextensions/01_installation.config
container_commands:
01_collectstatic:
command: "source /var/app/venv/*/bin/activate && python3 manage.py collectstatic --noinput"
.gitignore에 아래 파일을 추가합니다.
/static
/media/
.vscode/
.ebextensions/03_django.config
container_commands:
01_migrate:
command: "source /var/app/venv/*/bin/activate && python3 manage.py migrate"
leader_only: true
02_collectstatic:
command: "source /var/app/venv/*/bin/activate && python3 manage.py collectstatic --noinput"
leader_only: true
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: proj.wsgi:application
aws:elasticbeanstalk:environment:proxy:staticfiles:
/static: static
container_commands
- EC2 인스턴스 생성 시 자동으로 실행할 명령어 정의
01_migrate
- DB 마이그레이션 수행 (python manage.py migrate)
02_collectstatic
- 정적 파일 수집 (collectstatic --noinput)
leader_only: true
- 클러스터 환경일 경우 리더 인스턴스에서만 실행
WSGIPath
- Django의 WSGI 엔트리포인트 지정 (proj.wsgi:application)
/static: static
- /static 요청을 로컬 static/ 폴더에서 서빙 (Nginx 연동용)
배포전에
python manage.py check --deploy
python manage.py check --deploy
명령은 Django 프로젝트가 실제 배포 환경에 적합한지 보안 관련 설정들을 점검해주는 도구입니다.
launch.json이란?
.vscode/launch.json
은 Visual Studio Code에서 디버깅 환경을 설정하는 파일입니다.- 예를 들어 Django 서버를
python manage.py runserver
로 띄우는 명령어를 VSCode 내에서 버튼 하나로 실행/디버깅할 수 있게 도와줍니다.
로컬 개발, 디버깅 VSCode에서 F5
또는 ▶️ 버튼으로 runserver 실행 가능
성생된 json을 다음과 같이 수정합니다:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": ["runserver"],
"env": {"DEBUG": "1"},
"django": true,
"autoStartBrowser": false
}
]
}
그리고 디버깅 테스트를 합니다. 어드민이 잘 실행되면 성공입니다.
- 디버깅 설정 성공 ✅
- 서버 정상 기동 ✅
- 홈 페이지 접속 OK ✅
- favicon 404는 무시해도 됨 ✅